package com.niit.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.mapreduce.TableMapReduceUtil;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;

import java.io.IOException;

/**
 * Date:2024/11/22
 * Author：Ys
 * Description:
 */
public class WordCountDriver {

    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
        Configuration conf = new Configuration();

        Job job = Job.getInstance(conf);
        job.setJarByClass(WordCountDriver.class);

        //创建查询实例 Scan
        Scan scan = new Scan();
        scan.addColumn(Bytes.toBytes("C1"),Bytes.toBytes("receiver_phone_type"));
        //设置job读取输入的表
        TableMapReduceUtil.initTableMapperJob("MOMO_CHAT:MSG" ,scan, WordCountMapper.class, Text.class, IntWritable.class,job  );

        //设置job输出的表  create 'result','content'
        TableMapReduceUtil.initTableReducerJob("result", WordCountReduce.class,job);


        boolean result = job.waitForCompletion(true);

        System.exit( result ? 0 : 1);

    }
}
